//
//  UserCell.swift
//  mmda
//
//  Created by 李陆涛 on 2018/8/3.
//  Copyright © 2018年 mmda. All rights reserved.
//

import UIKit

class UserCell: UITableViewCell {
    
    @IBOutlet weak var userImageView: UIImageView!
    @IBOutlet weak var userNameLabel: UILabel!
    @IBOutlet weak var onlineTimeLabel: UILabel!
    @IBOutlet weak var introLabel: UILabel!
    
    private var user:User?
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    func setUser(_ user:User) {
        
        if let lastUser = self.user {
            
            if lastUser == user {
                
                return
            }
        }
        
        self.user = user
        
        userImageView.setImage(string: user.logo_new?.getQiniuThumb(thumbImageWidth), placeholder: #imageLiteral(resourceName: "default"))
        userNameLabel.text = user.nickname
        
        let time = user.updated_at?.leftTimeStringWithFormat("MM-dd HH:mm") ?? "未知"
        onlineTimeLabel.text = "最后活动于：\(time)"
        
        introLabel.text = user.label
    }
    
}
